#define _CRT_SECURE_NO_WARNINGS
#include"Sort.h"

TestBubbleSort()
{
	int a[] = { 24, 54, 4, 1, 3, 67, 43 };
	PrintArray(a, sizeof(a) / sizeof(a[0]));
	BubbleSort(a, sizeof(a) / sizeof(a[0]));
	PrintArray(a, sizeof(a) / sizeof(a[0]));
}

void TestQuickSort()
{
	int a[] = { 6, 1, 2, 7, 9, 3, 4, 5, 10, 8 };
	PrintArray(a, sizeof(a) / sizeof(a[0]));
	QuickSort(a, 0, 9);
	PrintArray(a, sizeof(a) / sizeof(a[0]));
}

void TestOP()
{
	srand(time(0));
	const int N = 1000000;
	int* a4 = (int*)malloc(sizeof(int) * N);
	int* a5= (int*)malloc(sizeof(int) * N);
	for (int i = 0; i < N; i++)
	{
		a4[i] = rand();
		a5[i] = a4[i];
	}

	int begin4 = clock();
	/*BubbleSort(a4, N);*/
	int end4 = clock();
	int begin5 = clock();
	QuickSort(a5, 0, N - 1);
	int end5= clock();
	printf("BubbleSort:%d\n", end4 - begin4);
	printf("QuickSort:%d\n", end5 - begin5);
	free(a4);
	free(a5);
}


void TestQuickSortNonR()
{
	int a[] = { 6, 1, 2, 7, 9, 3, 4, 5, 10, 8 };
	PrintArray(a, sizeof(a) / sizeof(a[0]));
	QuickSortNonR(a, 0, 9);
	PrintArray(a, sizeof(a) / sizeof(a[0]));
}

void TestMergeSort()
{
	int a[] = { 10, 6, 7, 1, 3, 9, 4, 2 };
	PrintArray(a, sizeof(a) / sizeof(a[0]));
	MergeSort(a, sizeof(a) / sizeof(a[0]));
	PrintArray(a, sizeof(a) / sizeof(a[0]));
}
int main()
{
	//TestBubbleSort();
	/*TestQuickSort();*/
	//TestQuickSortNonR();
	TestMergeSort();
	/*TestOP();*/
	return 0;
}